|
|
|
| |
|
|
|
|
some projects throughout this book, you find the databases are stored in the same directory as the sample projects. By using the App.Path property as part of the database name, you always point to the correct drive and directory for the required file. |
|
|
|
|
|
|
|
|
|
|
Listing 3.2. Declaring database and data table variables. |
|
|
|
|
|
|
|
|
Private Sub Form_Load()
'
' creating Dynaset-type recordsets
'
Dim db As Database ' the database object
Dim rs As Recordset ' the recordset object
'
' create local variables
Dim strDBName As String
Dim strRSName As String
'
' initialize the variables
strDBName = App.Path & "\..\data\books5.mdb"
strRSName = "Titles"
'
End Sub |
|
|
|
|
| |
|
|
|
|
Notice that you created two string variables, and both variable names start with the letters ''str", which stand for string type. This is the prefix of the variable name. The prefix of the name tells you what type of data is stored in the variable. This is common programming practice. Adhering to a strict naming convention makes it easier to read and maintain your programs. |
|
|
|
|
|
|
|
|
|
|
Before you continue with the chapter, save this form as DYNASETS.FRM and save the project as DYNASETS.VBP. |
|
|
|
|
|
|
|
|
Now that you have created the data objects, created variables to hold database properties, and initialized those variables with the proper values, you are ready to actually open the database and create the Dynaset-type Recordset. The code in Listing 3.3 shows how to do this using Visual Basic code. |
|
|
|
|
|